package pratice.fengzhongye.interview;

import org.junit.Test;

/**
 * @author 吴宇亮 on 2019/2/18 0018 15:12
 */
public class Lesson2_Static {

    @Test
    public void test1(){
        StaticTest instance = StaticTest.getInstance();
        System.out.println(instance.count1);
        System.out.println(instance.count2);
    }

}

/**
 * 面试：考察静态变量的初始化顺序。此外还有一个考察点，就是 静态代码块，构造代码块，构造方法的执行顺序
 */
class StaticTest{

    private static StaticTest st = new StaticTest();

    public static int count1;
    public static int count2 = 0;

    private StaticTest(){
        count1++;
        count2++;
    }

    public static StaticTest getInstance(){
        return st;
    }
}
